import createDraw from '@/utils/Draw'
import { Query } from '@/utils/Query'
import { message } from 'ant-design-vue'
import { ref, reactive, inject } from 'vue'
import { useStore } from 'vuex'
import $api from '@/request/api'
export const QUpdate = () => {
  const data = ref([])
  const Update = (map, formState) => {
    //console.log(formState.value.FID)
    //获取选中点要素FID
    let PntFID = formState.value.FID
    /* 1、设置查询结构 */
    const queryStruct = new Zondy.Service.QueryFeatureStruct()
    queryStruct.IncludeGeometry = true
    queryStruct.IncludeWebGraphic = true
    /* 2、设置查询参数 */
    const queryParam = new Zondy.Service.QueryParameter({
      struct: queryStruct,
      objectIds: PntFID,
    })
    /* 3、调用查询服务 */
    const queryService = new Zondy.Service.QueryDocFeature(
      queryParam,
      'guanggu_1',
      2,
      {
        ip: 'localhost',
        port: 6163,
      }
    )
    /* 4、回到 */
    queryService.query(querySuccess)
    //回调成功
    function querySuccess(result) {
      let resultPoint = result
      //设置添加点要素的属性信息
      resultPoint.SFEleArray[0].AttValue[7] = formState.value.事件状态
      //创建一个编辑服务类
      var editService = new Zondy.Service.EditDocFeature('guanggu_1', '2', {
        ip: 'localhost',
        port: '6163', //访问IGServer的端口号，.net版为6163，Java版为8089
      })
      editService.update(resultPoint, onPntSuccess)
    }
  }

  //修改点要素回调函数
  function onPntSuccess(data) {
    if (data.succeed) {
      message.success('修改点要素成功！')
      //刷新图层
      map.value.render()
    } else {
      message.error('修改点要素失败！')
    }
  }

  return {
    Update,
  }
}
